<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>IT行业职位需求分析系统</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<!-- basic styles -->
		<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="assets/css/font-awesome.min.css" />

		<!--[if IE 7]>
		  <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

		<!-- page specific plugin styles -->


		<!-- ace styles -->

		<link rel="stylesheet" href="assets/css/ace.min.css" />
		<link rel="stylesheet" href="assets/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="assets/css/ace-skins.min.css" />
		<link rel="stylesheet" href="assets/css/bootstrap-table.css" />

		<!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->

		<script src="assets/js/ace-extra.min.js"></script>

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

		<!--[if lt IE 9]>
		<script src="assets/js/html5shiv.js"></script>
		<script src="assets/js/respond.min.js"></script>
		<![endif]-->
	</head>

	<body>
		<div class="navbar navbar-default" id="navbar">
			<script type="text/javascript">
				try{ace.settings.check('navbar' , 'fixed')}catch(e){}
			</script>

			<div class="navbar-container" id="navbar-container">
				<div class="navbar-header pull-left">
					<a href="#" class="navbar-brand">
						<small>
							<i class="icon-leaf"></i>
							IT行业职位需求分析系统
						</small>
					</a><!-- /.brand -->
				</div><!-- /.navbar-header -->

				<div class="navbar-header pull-right" role="navigation">
					<ul class="nav ace-nav">
						<li class="light-blue">
							<a data-toggle="dropdown" href="#" class="dropdown-toggle">
								<img class="nav-user-photo" src="assets/avatars/user.jpg" alt="Jason's Photo" />
								<span class="user-info">
									<small>欢迎光临</small>
								</span>

								<i class="icon-caret-down"></i>
							</a>

							<ul class="user-menu pull-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
								<li>
									<a href="login.html">
										<i class="icon-off"></i>
										退出
									</a>
								</li>
							</ul>
						</li>
					</ul><!-- /.ace-nav -->
				</div><!-- /.navbar-header -->
			</div><!-- /.container -->
		</div>

		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<a class="menu-toggler" id="menu-toggler" href="#">
					<span class="menu-text"></span>
				</a>

				<div class="sidebar" id="sidebar">
					<script type="text/javascript">
						try{ace.settings.check('sidebar' , 'fixed')}catch(e){}
					</script>

					<ul class="nav nav-list">
						<li>
							<a href="index.html">
								<i class="icon-dashboard"></i>
								<span class="menu-text"> 控制台 </span>
							</a>
						</li>

						<li>
                            <a href="data.html" class="dropdown-toggle">
                                <i class="icon-tag"></i>
                                <span class="menu-text"> 数据总览 </span>
                            </a>
                        </li>
                        <li>
                            <a href="area.html" class="dropdown-toggle">
                                <i class="icon-tag"></i>
                                <span class="menu-text"> 地区分析 </span>
                            </a>
                        </li>

                        <li>
                            <a href="education.html" class="dropdown-toggle">
                                <i class="icon-tag"></i>
                                <span class="menu-text"> 教育分析 </span>
                            </a>
                        </li>

                        <li>
                            <a href="experience.html" class="dropdown-toggle">
                                <i class="icon-tag"></i>
                                <span class="menu-text"> 经验分析 </span>
                            </a>
                        </li>

						<li class="active">
							<a href="user.html">
								<i class="icon-edit"></i>
								<span class="menu-text"> 用户管理 </span>
							</a>
						</li>

						<li>
							<a href="crawler.html">
								<i class="icon-list-alt"></i>
								<span class="menu-text"> 数据获取 </span>
							</a>
						</li>
					</ul><!-- /.nav-list -->

					<div class="sidebar-collapse" id="sidebar-collapse">
						<i class="icon-double-angle-left" data-icon1="icon-double-angle-left" data-icon2="icon-double-angle-right"></i>
					</div>

					<script type="text/javascript">
						try{ace.settings.check('sidebar' , 'collapsed')}catch(e){}
					</script>
				</div>

				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>

						<ul class="breadcrumb">
							<li>
								<i class="icon-home home-icon"></i>
								<a href="#">首页</a>
							</li>
							<li class="active">用户管理</li>
						</ul><!-- .breadcrumb -->

					</div>

					<div class="page-content">
						<div class="page-header">
							<h1>
								用户管理
								<small>
									<i class="icon-double-angle-right"></i>
									 查看
								</small>
							</h1>
						</div><!-- /.page-header -->

						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->

								<div class="alert alert-block alert-success">
									<button type="button" class="close" data-dismiss="alert">
										<i class="icon-remove"></i>
									</button>

									<i class="icon-ok green"></i>
									查询用户信息
								</div>
								<!-- 搜索框 -->
					            <div class="panel-body">
					                <form role="form" id="searchForm" class="form-inline">
					                    <div class="form-group"> <input type="text"
					                            class="form-control" id="sname1" name="sname1" placeholder="请输入名称">
					                    </div>
					                    <div class="form-group">
					                        <button type="button" id="searchBtn" class="btn btn-default">开始搜索</button>
					                    </div>
					                </form>
					            </div>
								<table id="table"></table>
								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div> <!-- /.row -->
					</div><!-- /.page-content -->
				</div><!-- /.main-content -->
			</div><!-- /.main-container-inner -->

			<!-- 操作模态框 -->
			<div class="modal fade" id="opDataxJobRowModal" tabindex="-1" role="dialog" >
			  <div class="modal-dialog" role="document">
			    <div class="modal-content">
			      <div class="modal-header">
			        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			        <h4 class="modal-title" id="exampleModalLabel">警告</h4>
			      </div>
			      <div class="modal-body">
		                <strong id="warningText"></strong>
			      </div>
			      <div class="modal-footer">
			        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			        <button type="button" class="btn btn-danger" id="confirmBtn"></button>
			      </div>
			    </div>
			  </div>
			</div>
			<!-- 操作成功提示模态框 -->
			<div id="opSuccessModal" class="modal fade " tabindex="-1" role="dialog" >
			  <div class="modal-dialog modal-sm" role="document">

			    <div class="modal-content">
			        <div class="modal-header">
			            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			            <h4 class="modal-title">提示</h4>
			        </div>
			        <div class="modal-body">
			            <p style="color:green">操作成功，删除成功</p>
			        </div>
			    </div>
			  </div>
			</div>
			<!-- 操作失败提示模态框 -->
			<div id="opFailedModal" class="modal fade " tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
			  <div class="modal-dialog modal-sm" role="document">

			    <div class="modal-content">
			        <div class="modal-header">
			            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			            <h4 class="modal-title">提示</h4>
			        </div>
			        <div class="modal-body">
			            <p style="color:red" id="opFaildeMessage">操作失败，该用户不存在</p>
			        </div>
			    </div>
			  </div>
			</div>

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

		<!-- basic scripts -->


		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"script>");
		</script>
		<script src="assets/js/bootstrap.min.js"></script>
		<script src="assets/js/typeahead-bs2.min.js"></script>

		<!-- page specific plugin scripts -->

		<!--[if lte IE 8]>
		  <script src="assets/js/excanvas.min.js"></script>
		<![endif]-->

		<script src="assets/js/jquery-ui-1.10.3.custom.min.js"></script>
		<script src="assets/js/jquery.ui.touch-punch.min.js"></script>
		<script src="assets/js/jquery.slimscroll.min.js"></script>
		<script src="assets/js/jquery.easy-pie-chart.min.js"></script>
		<script src="assets/js/jquery.sparkline.min.js"></script>

		<!-- ace scripts -->

		<script src="assets/js/ace-elements.min.js"></script>
		<script src="assets/js/ace.min.js"></script>
		<script src="assets/js/table/bootstrap-table.js"></script>
		<script src="assets/js/table/bootstrap-table-zh-CN.js"></script>

		<!-- inline scripts related to this page -->

		<script type="text/javascript">
			// 初始化表格数据
			$(function(){
				init()
			});
			function init(){
				$('#table').bootstrapTable("showLoading");
				$.ajax({ 
					url: "http://127.0.0.1:8081/api/user/get_user_list/",
					method: "get",
					dataType: "json",
					success: function(rs){
						var message = rs.results
		                $('#table').bootstrapTable('load', message);
						$('#table').bootstrapTable('refresh');
						$('#table').bootstrapTable("hideLoading");
					},
				})
			};
			// 初始化表格
			$('#table').bootstrapTable({
				cache:false,
				clickToSelect:true,
				pageSize: 15,
				pageNumber: 1,
				pagination: true,
				columns: [{
					field: 'id',
			    	title: '编号'
			  	}, {
			    	field: 'username',
			    	title: '用户名'
			  	}, {
			    	field: 'gender',
			    	title: '性别'
			  	}, {
			    	field: 'email',
			    	title: '邮箱'
			  	}, {
			    	field: 'address',
			    	title: '地址'
			  	}, {
			    	field: 'mobile',
			    	title: '手机号'
			  	}, {
			    	field: 'operate',
			    	title: '操作',
			    	formatter:function(value,row,index){
		                return '<a  id="runDataxJob" class="btn btn-xs btn-danger"><i class="fa fa-delete"></i> 删除</a>';
		            },
		            events: {
						'click #runDataxJob': function (e, value, row, index) {
							//动态控制模态框的显示内容，为模态框的按钮动态的绑定事件，包括删除事件和执行事件，
							//这样模态框就可以复用
							$("#warningText").text("是否删除用户为： " +row.username);
							$("#confirmBtn").text("确认");
							$("#confirmBtn").on("click",function(){
								delete_user(row)
							});
							$("#opDataxJobRowModal").modal();
						}
					}
			  	}]
			});
			// 搜索
			$("#searchBtn").click(function() {
                var sname1 = $("#sname1").val();
                $.ajax({
                     type: "get",
                     url: "http://127.0.0.1:8081/api/user/get_user_by_name/",
                     cache: false,
                     data: {username : sname1},
                     success : function(res) {
                     	var message1 = res.results
                        $("#table").bootstrapTable('load', message1);//主要是要这种写法
						$('#table').bootstrapTable('refresh');
                    }
                });

            });

            // 删除用户
			function delete_user(row){
				$.ajax({
                     type: "delete",
                     url: "http://127.0.0.1:8081/api/user/delete_user",
                     cache: false,
                     data: {username : row.username},
                     success : function(res) {
						$("#opDataxJobRowModal").modal('toggle');
                     	if(res.status == "ok"){
			                $("#opSuccessModal").modal();
							init()
                     	}else{
                			$("#opFailedModal").modal();
                     	}
                    }
                });
			}
		</script>
</body>
</html>

